<script setup>
import { reactive } from 'vue'
import useInputValidate from './composable/useInputValidate'

const { handleBlur, handleValidate } = useInputValidate({ min: 0, max: 100, type: 'integer' })

const form = reactive({
  integer: '',
  number: '',
  price_low: '',
  price_high: '',
})
</script>

<template>
  <div>
    <h1>Input-Validator</h1>
    <el-form>
      <el-form-item>
        <el-input
          placeholder="请输入整数"
          v-model="form.integer"
          @input="form.integer = handleValidate(form.integer)"
          @blur="form.integer = handleBlur(form.integer)"
        ></el-input>
      </el-form-item>
      <!-- <el-form-item>
        <el-input
          placeholder="请输入数值"
          v-model="form.number"
          @input="form.number = validateNumber(form.number)"
          @blur="form.number = handleBlur(form.number)"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-input placeholder="最低价" v-model="form.price_low"></el-input>
        —
        <el-input placeholder="最高价" v-model="form.price_high"></el-input>
      </el-form-item> -->
    </el-form>
  </div>
</template>

<style lang="scss" scoped>
:deep() {
  .el-input {
    display: inline-block;
    width: 200px;
  }
}
</style>
